﻿Imports ccapps.persistent.TanimsizHat
Imports System.Data.OleDb

Public Class TanimsizHatCustomerCreate
    Inherits System.Web.UI.Page

    Dim i, i2
    Dim a As Integer
    Dim citycode As String





    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Session("user") = "" Or Session("user") Is Nothing Then
            ' Response.Redirect("../../login.aspx")
            Session("message") = "!!Session Timeout!!,Tekrar Giriş Yapmalısınız"
            Response.Clear()
            Response.Status = "302 Object Moved"
            Response.RedirectLocation = "CX_Exception.aspx"
            Response.End()
        End If

        Session("LATop") = 0

        KurumsalTable.Visible = False
        HidTable1.Visible = False
        hidTable2.Visible = False
        hidTable3.Visible = False
        YeniTable.Visible = False
        MevcutTable.Visible = False
        SubLevel.Visible = False
        ErrorMessage.Visible = False
        MevcutTable2.Visible = False


        If lblcode.Text = "hidtable" Then
            HidTable1.Visible = True
            hidTable2.Visible = False
            hidTable3.Visible = False
            YeniTable.Visible = False
            KurumsalTable.Visible = False
            SubLevel.Visible = False
            MevcutTable.Visible = False
            ErrorMessage.Visible = False
            MevcutTable2.Visible = False
        End If
        If lblcode.Text = "kurumsal" Then
            KurumsalTable.Visible = True
            HidTable1.Visible = False
            hidTable2.Visible = False
            MevcutTable.Visible = False
            ErrorMessage.Visible = False
            SubLevel.Visible = False
            YeniTable.Visible = False
            hidTable3.Visible = False
            MevcutTable2.Visible = False
        End If
        If lblcode.Text = "mevcut" Then
            KurumsalTable.Visible = True
            HidTable1.Visible = False
            hidTable2.Visible = False
            MevcutTable.Visible = False
            MevcutTable2.Visible = True
            ErrorMessage.Visible = False
            SubLevel.Visible = False
            YeniTable.Visible = False
            hidTable3.Visible = False
        End If
        If lblcode.Text = "kurumsalYeni" Then
            hidTable2.Visible = True
            KurumsalTable.Visible = True
            HidTable1.Visible = False
            MevcutTable.Visible = False
            MevcutTable2.Visible = False
            YeniTable.Visible = False
            ErrorMessage.Visible = False
            SubLevel.Visible = False
            hidTable3.Visible = False
        End If
        If lblcode.Text = "la" Then
            hidTable2.Visible = False
            KurumsalTable.Visible = False
            HidTable1.Visible = False
            MevcutTable.Visible = False
            MevcutTable2.Visible = False
            YeniTable.Visible = False
            ErrorMessage.Visible = False
            SubLevel.Visible = False
            hidTable3.Visible = True
        End If
        If lblcode.Text = "sublevel" Then
            hidTable2.Visible = False
            KurumsalTable.Visible = False
            HidTable1.Visible = False
            MevcutTable.Visible = True
            MevcutTable2.Visible = False
            YeniTable.Visible = False
            ErrorMessage.Visible = False
            SubLevel.Visible = True
            hidTable3.Visible = True
        End If
        If lblcode.Text = "toplevel" Then
            hidTable2.Visible = False
            KurumsalTable.Visible = False
            HidTable1.Visible = False
            MevcutTable2.Visible = False
            ErrorMessage.Visible = False
            SubLevel.Visible = False
            YeniTable.Visible = True
            MevcutTable.Visible = False
            hidTable3.Visible = True
        End If




        'If i = 3 Then
        '    hidTable3.Visible = True
        '    If i2 = 1 Then
        '        hidTable3.Visible = True
        '        YeniTable.Visible = True
        '        MevcutTable.Visible = False
        '    End If
        '    If i2 = 2 Then
        '        hidTable3.Visible = True
        '        YeniTable.Visible = False
        '        MevcutTable.Visible = True
        '    End If
        'End If





    End Sub











    Protected Sub RadioButtonList1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles RadioButtonList1.SelectedIndexChanged

        If RadioButtonList1.SelectedIndex = 0 Then
            Clear()
            HidTable1.Visible = True
            hidTable2.Visible = False
            hidTable3.Visible = False
            YeniTable.Visible = False
            KurumsalTable.Visible = False
            SubLevel.Visible = False
            MevcutTable.Visible = False
            ErrorMessage.Visible = False
            MevcutTable2.Visible = False

            MusteriGrubu()
            AktivasyonReason()
            IlSecim()
            IlceSecim()
            TarifeSecim()
            UlkeSecim()
            KimlikSecim()
            DDL_ADR_NATIONALITY.SelectedValue = 2
            lblcode.Text = "hidtable"
            RadioButtonList2.ClearSelection()
            RadioButtonList3.ClearSelection()

        End If
        If RadioButtonList1.SelectedIndex = 1 Then
            Clear()
            KurumsalTable.Visible = True
            HidTable1.Visible = False
            hidTable2.Visible = False
            MevcutTable.Visible = False
            ErrorMessage.Visible = False
            SubLevel.Visible = False
            YeniTable.Visible = False
            hidTable3.Visible = False
            MevcutTable2.Visible = False
            UlkeSecimSME()
            SME_DDL_ADR_NATIONALITY.SelectedValue = 2
            lblcode.Text = "kurumsal"
            RadioButtonList2.ClearSelection()
            RadioButtonList3.ClearSelection()


        End If


        If RadioButtonList1.SelectedIndex = 2 Then
            Clear()
            hidTable2.Visible = False
            KurumsalTable.Visible = False
            HidTable1.Visible = False
            MevcutTable.Visible = False
            MevcutTable2.Visible = False
            YeniTable.Visible = False
            ErrorMessage.Visible = False
            SubLevel.Visible = False
            hidTable3.Visible = True
            i = 3
            MusteriGrubuLATop()
            AktivasyonReasonLATop()
            IlSecimLATop()
            IlceSecimLATop()
            TarifeSecimLATop()
            KimlikSecimLATop()
            lblcode.Text = "la"
            RadioButtonList2.ClearSelection()
            RadioButtonList3.ClearSelection()

        End If

    End Sub









    Protected Sub RadioButtonList2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles RadioButtonList2.SelectedIndexChanged
        If RadioButtonList2.SelectedIndex = 0 Then
            YeniTable.Visible = True
            MevcutTable.Visible = False
            hidTable3.Visible = True
            SubLevel.Visible = False
            lblcode.Text = "toplevel"
            i2 = 1
        End If
        If RadioButtonList2.SelectedIndex = 1 Then
            MevcutTable.Visible = True
            YeniTable.Visible = False
            hidTable3.Visible = True
            SubLevel.Visible = False
            i2 = 2
            MusteriGrubuLASub()
            AktivasyonReasonLASub()
            IlSecimLASub()
            IlceSecimLASub()
            TarifeSecimLASub()
            KimlikSecimLASub()
            lblcode.Text = "sublevel"
        End If
    End Sub

    Protected Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
        Dim gen As String = "adsda"
        Clear()

        hidTable3.Visible = True

        SubLevel.Visible = True

        MusteriGrubuLASub()
        AktivasyonReasonLASub()
        IlSecimLASub()
        IlceSecimLASub()
        TarifeSecimLASub()
        KimlikSecimLASub()
        hiddentr.Visible = False


        If (BilgiKopyala.Checked = True) Then
            SubCustomerSearch()
            hiddentr.Visible = True
            SUB_DDL1_ADR_CITY.Enabled = False
            SUB_DDL1_ADR_NOTE1.Enabled = False

        Else
            SUB_DDL1_ADR_CITY.Enabled = True
            SUB_DDL1_ADR_NOTE1.Enabled = True
            SubCustomerSearchForNonChecked()

        End If
        MevcutTable.Visible = True
        SubLevel.Visible = True


    End Sub


    Private Sub SubCustomerSearch()
        Try
            Dim custcode As String = TB_CustCode.Text

            Dim dt2 As DataTable = LASubCustCodeSearch(custcode)
            Dim gen As Integer
            Dim prgcode_num As String
            Dim gen1 As Integer = Convert.ToInt32(hid.Text)
            If dt2.Rows.Count > 0 Then
                For Each dr2 As DataRow In dt2.Rows

                    gen = Convert.ToInt32(dr2("CUSTOMER_ID").ToString())
                    prgcode_num = dr2("prgcode").ToString()
                Next
                hid.Text = gen

            End If

            Dim dt As DataTable = LASubCustInfoSearch(gen1)
            If dt.Rows.Count > 0 Then
                For Each dr As DataRow In dt.Rows
                    Dim il, ilce, birthdate, ccsex As String
                    birthdate = dr("BIRTHDATE").ToString()
                    SUB_TB_CS_REMARK1.Text = dr("csremark_1").ToString()
                    If birthdate = "" Or birthdate = Nothing Then
                        SUB_TDD_ADR_BIRTHDT.Text = ""
                    Else
                        SUB_TDD_ADR_BIRTHDT.Text = birthdate.Substring(0, 10)
                    End If
                    SUB_TB_CS_REMARK2.Text = dr("csremark_2").ToString().ToUpper()
                    SUB_TB_CS_REG_DISTRICT.Text = dr("REGISTERED_DISTRICT").ToString().ToUpper()
                    SUB_TB_CS_REG_PROVINCE.Text = dr("REGISTERED_PROVINCE").ToString().ToUpper()
                    SUB_TB_CS_BIRTH_PROVINCE.Text = dr("BIRTH_PLACE_PROVINCE").ToString().ToUpper()
                    SUB_TB_ADR_TAXNO.Text = dr("cscomptaxno").ToString().ToUpper()
                    SUB_TB_ADR_COMPNO.Text = dr("cscompregno").ToString().ToUpper()
                    SUB_TB_ADR_NAME.Text = dr("ccname").ToString().ToUpper()
                    SUB_TB_ADR_FNAME.Text = dr("ccfname").ToString().ToUpper()
                    SUB_TB_ADR_LNAME.Text = dr("cclname").ToString().ToUpper()
                    SUB_TB1_ADR_STREETNO.Text = dr("ccstreetno").ToString().ToUpper()
                    'SUB_TB1_ADR_STREET.Text = dr("ccstreet").ToString().ToUpper()
                    SUB_DDL1_ADR_SEMT.Items.Clear()
                    SUB_DDL1_ADR_SEMT.Items.Add(New ListItem(dr("ccstreet"), 0))
                    SUB_TB1_ADR_ZIP.Text = dr("CCZIP").ToString().ToUpper()
                    SUB_TB_ADR_PHN1_AREA.Text = dr("cctn_area").ToString().ToUpper()
                    SUB_TB_ADR_PHN2_AREA.Text = dr("cctn2_area").ToString().ToUpper()
                    SUB_TB_ADR_PHN1.Text = dr("cctn").ToString().ToUpper()
                    SUB_TB_ADR_PHN2.Text = dr("cctn2").ToString().ToUpper()
                    SUB_TB_ADR_NOTE2.Text = dr("CCADDR2").ToString().ToUpper()
                    ccsex = dr("ccsex").ToString().ToUpper()
                    If ccsex = "F" Then
                        SUB_DDL_ADR_SEX.SelectedValue = "F"

                    ElseIf dr("ccsex").ToString() = "M" Then

                        SUB_DDL_ADR_SEX.SelectedValue = "M"
                    End If
                    SUB_DDL1_ADR_NOTE1.Items.Clear()
                    il = dr("CCCITY").ToString()
                    If il.IndexOf("-") = -1 Then
                        SUB_DDL1_ADR_CITY.Items.Clear()
                        SUB_DDL1_ADR_CITY.Items.Add(New ListItem(dr("CCCITY"), 0))
                        SUB_DDL1_ADR_NOTE1.Items.Clear()
                        SUB_DDL1_ADR_NOTE1.Items.Add(New ListItem(dr("CCLINE2"), 0))
                    Else
                        Dim il1() As String = il.Split("-")
                        SUB_DDL1_ADR_CITY.Items.Clear()
                        SUB_DDL1_ADR_CITY.Items.Add(New ListItem(il1(0), 0))
                        SUB_DDL1_ADR_NOTE1.Items.Clear()
                        SUB_DDL1_ADR_NOTE1.Items.Add(New ListItem(il1(1), 0))
                    End If

                    'Eski Kod'
                    'SUB_DDL1_ADR_NOTE1.Items.Add(New ListItem(dr("DIST_DES").ToString(), dr("DIST_COD").ToString()))
                    ' SUB_DDL1_ADR_CITY.Items.Add(New ListItem(dr("CITY_DES").ToString(), dr("CITY_COD").ToString()))
                    SUB_TB_ADR_SMSNO.Text = dr("ccsmsno").ToString().ToUpper()
                    SUB_TB_ADR_EMAIL.Text = dr("CCEMAIL").ToString().ToUpper()
                    SUB_TB_ADR_IDNO.Text = dr("passportno").ToString().ToUpper()
                    SUB_DLL_PRG_CODE.SelectedValue = prgcode_num.ToUpper()
                    TarifeSecimLASub()
                Next
            End If
        Catch ex As Exception

        End Try
       
    End Sub

    Private Sub SubCustomerSearchForNonChecked()

        Dim custcode As String = TB_CustCode.Text

        Dim dt2 As DataTable = LASubCustCodeSearch(custcode)
        Dim gen As Integer
        Dim prgcode_num As String
        Dim gen1 As Integer = Convert.ToInt32(hid.Text)
        If dt2.Rows.Count > 0 Then
            For Each dr2 As DataRow In dt2.Rows

                gen = Convert.ToInt32(dr2("CUSTOMER_ID").ToString())
                prgcode_num = dr2("prgcode").ToString()
            Next
            hid.Text = gen

        End If

        Dim dt As DataTable = LASubCustInfoSearch(gen1)
        If dt.Rows.Count > 0 Then
            For Each dr As DataRow In dt.Rows
                SUB_DLL_PRG_CODE.SelectedValue = prgcode_num
            Next
        End If
        TarifeSecimLASub()
    End Sub

    Private Sub TarifeSecimLASub()
        SUB_DLL_RPCODE.Items.Clear()
        If (SUB_DLL_PRG_CODE.SelectedItem.ToString() = "--Seçiniz--") Then


        Else
            Dim musteri_code As Integer = SUB_DLL_PRG_CODE.SelectedValue



            Dim dt3 As DataTable = TarifeTypeLA(musteri_code)

            If dt3.Rows.Count > 0 Then
                For Each dr3 As DataRow In dt3.Rows
                    SUB_DLL_RPCODE.Items.Add(New ListItem(dr3("des").ToString(), dr3("tmcode").ToString()))

                Next
            End If

        End If


    End Sub


    Private Sub KimlikSecimLASub()
        SUB_DDL_IDTYPE_CODE.Items.Clear()
        SUB_DDL_IDTYPE_CODE.Items.Add(New ListItem("--Seçiniz--", "--Seçiniz--"))

        Dim dt As DataTable = KimlikType()

        If dt.Rows.Count > 0 Then
            For Each dr As DataRow In dt.Rows
                SUB_DDL_IDTYPE_CODE.Items.Add(New ListItem(dr("IDTYPE_NAME").ToString(), dr("IDTYPE_CODE").ToString()))
            Next
        End If
    End Sub

    Private Sub MusteriGrubuLASub()
        SUB_DLL_PRG_CODE.Items.Clear()
        SUB_DLL_PRG_CODE.Items.Add(New ListItem("--Seçiniz--", "--Seçiniz--"))
        Dim dt As DataTable = TanimsizgetcustomertypeLA()

        If dt.Rows.Count > 0 Then
            For Each dr As DataRow In dt.Rows
                SUB_DLL_PRG_CODE.Items.Add(New ListItem(dr("prgname").ToString(), dr("prgcode").ToString()))
            Next
        End If
    End Sub



    Private Sub IlceSecimLASub()

        SUB_DDL1_ADR_SEMT.Items.Clear()
        SUB_TB1_ADR_ZIP.Text = ""

        Try

            If (SUB_DDL1_ADR_CITY.SelectedItem.ToString() = "--Seçiniz--") Then

            Else
                SUB_DDL1_ADR_NOTE1.Items.Clear()
                Dim citycode As String = SUB_DDL1_ADR_CITY.SelectedValue.ToString()
                lblcitycode.Text = citycode

                Dim dt As DataTable = New DataTable()
                SUB_DDL1_ADR_NOTE1.Items.Add(New ListItem("--Seçiniz--", "--Seçiniz--"))
                dt = ccapps.persistent.YenidenAktivasyon.IlceType(citycode)

                SUB_DDL1_ADR_NOTE1.Items.Clear()


                SUB_DDL1_ADR_NOTE1.Items.Add(New ListItem("--Seçiniz--", "--Seçiniz--"))
                For Each dr2 As DataRow In dt.Rows

                    SUB_DDL1_ADR_NOTE1.Items.Add(New ListItem(dr2("DIST_DES").ToString(), dr2("DIST_COD").ToString()))
                Next
            End If
        Catch ex As Exception


        End Try
      
    End Sub





    Private Sub IlSecimLASub()
        Try

            SUB_DDL1_ADR_CITY.Items.Clear()
            SUB_DDL1_ADR_CITY.Items.Add(New ListItem("--Seçiniz--", "--Seçiniz--"))
            Dim dt As DataTable = New DataTable()
            dt = ccapps.persistent.YenidenAktivasyon.IlType
            For Each dr2 As DataRow In dt.Rows
                SUB_DDL1_ADR_CITY.Items.Add(New ListItem(dr2("ctydes").ToString(), dr2("ctycod").ToString()))
            Next
        Catch ex As Exception

        End Try
    

     
    End Sub




    Private Sub AktivasyonReasonLASub()
        SUB_DLL_RS_CODE.Items.Clear()
        SUB_DLL_RS_CODE.Items.Add(New ListItem("--Seçiniz--", "--Seçiniz--"))
        Dim dt2 As DataTable = aktivasyonType()


        If dt2.Rows.Count > 0 Then
            For Each dr2 As DataRow In dt2.Rows
                SUB_DLL_RS_CODE.Items.Add(New ListItem(dr2("rs_desc").ToString(), dr2("RS_ID").ToString())) 'rs_desc ve rscode Databasedeki sql variablelarının isimleri' 
            Next
        End If
    End Sub

    Private Sub TarifeSecimSME()
        SME_DLL_RPCODE.Items.Clear()
        If (SME_DLL_PRG_CODE.SelectedItem.ToString() = "--Seçiniz--") Then


        Else

            Dim musteri_code As Integer = SME_DLL_PRG_CODE.SelectedValue



            Dim dt3 As DataTable = TarifeTypeSME(musteri_code)

            If dt3.Rows.Count > 0 Then
                For Each dr3 As DataRow In dt3.Rows
                    SME_DLL_RPCODE.Items.Add(New ListItem(dr3("des").ToString(), dr3("tmcode").ToString()))

                Next
            End If

        End If


    End Sub


    Private Sub KimlikSecimSME()
        Try
            SME_DDL_IDTYPE_CODE.Items.Clear()
            SME_DDL_IDTYPE_CODE.Items.Add(New ListItem("--Seçiniz--", "--Seçiniz--"))
            Dim dt As DataTable = KimlikType()

            If dt.Rows.Count > 0 Then
                For Each dr As DataRow In dt.Rows
                    SME_DDL_IDTYPE_CODE.Items.Add(New ListItem(dr("IDTYPE_NAME").ToString(), dr("IDTYPE_CODE").ToString()))
                Next
            End If
        Catch ex As Exception

        End Try
        
    End Sub

    Private Sub MusteriGrubuSME()
        Try
            SME_DLL_PRG_CODE.Items.Clear()
            SME_DLL_PRG_CODE.Items.Add(New ListItem("--Seçiniz--", "--Seçiniz--"))
            Dim dt As DataTable = TanimsizgetcustomertypeSME()

            If dt.Rows.Count > 0 Then
                For Each dr As DataRow In dt.Rows
                    SME_DLL_PRG_CODE.Items.Add(New ListItem(dr("prgname").ToString(), dr("prgcode").ToString()))
                Next
            End If
        Catch ex As Exception

        End Try
       
    End Sub



    Private Sub IlceSecimSME()
        SME_DDL1_ADR_SEMT.Items.Clear()
        SME_TB1_ADR_ZIP.Text = ""

        Try

            If (SME_DDL1_ADR_CITY.SelectedItem.ToString() = "--Seçiniz--") Then

            Else
                SME_DDL1_ADR_NOTE1.Items.Clear()
                Dim citycode As String = SME_DDL1_ADR_CITY.SelectedValue.ToString()
                lblcitycode.Text = citycode

                Dim dt As DataTable = New DataTable()
                SME_DDL1_ADR_NOTE1.Items.Add(New ListItem("--Seçiniz--", "--Seçiniz--"))
                dt = ccapps.persistent.YenidenAktivasyon.IlceType(citycode)

                SME_DDL1_ADR_NOTE1.Items.Clear()


                SME_DDL1_ADR_NOTE1.Items.Add(New ListItem("--Seçiniz--", "--Seçiniz--"))
                For Each dr2 As DataRow In dt.Rows

                    SME_DDL1_ADR_NOTE1.Items.Add(New ListItem(dr2("DIST_DES").ToString(), dr2("DIST_COD").ToString()))
                Next
            End If
        Catch ex As Exception


        End Try

    End Sub





    Private Sub IlSecimSME()
        Try


            SME_DDL1_ADR_CITY.Items.Clear()
            SME_DDL1_ADR_CITY.Items.Add(New ListItem("--Seçiniz--", "--Seçiniz--"))
            Dim dt As DataTable = New DataTable()
            dt = ccapps.persistent.YenidenAktivasyon.IlType
            For Each dr2 As DataRow In dt.Rows
                SME_DDL1_ADR_CITY.Items.Add(New ListItem(dr2("ctydes").ToString(), dr2("ctycod").ToString()))
            Next
        Catch ex As Exception

        End Try
     
    End Sub




    Private Sub AktivasyonReasonSME()
        Try
            SME_DLL_RS_CODE.Items.Clear()
            SME_DLL_RS_CODE.Items.Add(New ListItem("--Seçiniz--", "--Seçiniz--"))
            Dim dt2 As DataTable = aktivasyonType()


            If dt2.Rows.Count > 0 Then
                For Each dr2 As DataRow In dt2.Rows
                    SME_DLL_RS_CODE.Items.Add(New ListItem(dr2("rs_desc").ToString(), dr2("RS_ID").ToString())) 'rs_desc ve rscode Databasedeki sql variablelarının isimleri' 
                Next
            End If
        Catch ex As Exception

        End Try
      
    End Sub

    Protected Sub SME_DDL1_ADR_CITY_SelectedIndexChanged(sender As Object, e As EventArgs) Handles SME_DDL1_ADR_CITY.SelectedIndexChanged
        hidTable2.Visible = True

        IlceSecimSME()
    End Sub

    Protected Sub SME_DLL_PRG_CODE_SelectedIndexChanged(sender As Object, e As EventArgs) Handles SME_DLL_PRG_CODE.SelectedIndexChanged
        hidTable2.Visible = True

        TarifeSecimSME()
    End Sub


    Private Sub TarifeSecim()
        Try
            DLL_RPCODE.Items.Clear()
            If (DLL_PRG_CODE.SelectedItem.ToString() = "--Seçiniz--") Then

            Else

                Dim musteri_code As Integer = DLL_PRG_CODE.SelectedValue



                Dim dt3 As DataTable = TarifeType(musteri_code)

                If dt3.Rows.Count > 0 Then
                    For Each dr3 As DataRow In dt3.Rows
                        DLL_RPCODE.Items.Add(New ListItem(dr3("des").ToString(), dr3("tmcode").ToString()))

                    Next
                End If

            End If
        Catch ex As Exception

        End Try
       


    End Sub


    Private Sub KimlikSecim()
        Try
            DDL_IDTYPE_CODE.Items.Clear()
            DDL_IDTYPE_CODE.Items.Add(New ListItem("--Seçiniz--", "--Seçiniz--"))

            Dim dt As DataTable = KimlikType()

            If dt.Rows.Count > 0 Then
                For Each dr As DataRow In dt.Rows
                    DDL_IDTYPE_CODE.Items.Add(New ListItem(dr("IDTYPE_NAME").ToString(), dr("IDTYPE_CODE").ToString()))
                Next
            End If
        Catch ex As Exception

        End Try
        
    End Sub

    Private Sub MusteriGrubu()
        Try
            DLL_PRG_CODE.Items.Clear()
            DLL_PRG_CODE.Items.Add(New ListItem("--Seçiniz--", "--Seçiniz--"))
            Dim dt As DataTable = Tanimsizgetcustomertype()

            If dt.Rows.Count > 0 Then
                For Each dr As DataRow In dt.Rows
                    DLL_PRG_CODE.Items.Add(New ListItem(dr("prgname").ToString(), dr("prgcode").ToString()))
                Next
            End If
        Catch ex As Exception

        End Try

       
    End Sub

    Private Sub UlkeSecim()
        Try
            DDL_ADR_NATIONALITY.Items.Clear()
            DDL_ADR_NATIONALITY.Items.Add(New ListItem("--Seçiniz--", "--Seçiniz--"))
            Dim dt As DataTable = CountryType()

            If dt.Rows.Count > 0 Then
                For Each dr As DataRow In dt.Rows
                    DDL_ADR_NATIONALITY.Items.Add(New ListItem(dr("NAME").ToString(), dr("COUNTRY_ID").ToString()))
                Next
            End If
        Catch ex As Exception

        End Try

       
    End Sub
    Private Sub UlkeSecimSME()
        Try
            SME_DDL_ADR_NATIONALITY.Items.Clear()
            SME_DDL_ADR_NATIONALITY.Items.Add(New ListItem("--Seçiniz--", "--Seçiniz--"))
            Dim dt As DataTable = CountryType()

            If dt.Rows.Count > 0 Then
                For Each dr As DataRow In dt.Rows
                    SME_DDL_ADR_NATIONALITY.Items.Add(New ListItem(dr("NAME").ToString(), dr("COUNTRY_ID").ToString()))
                Next
            End If
        Catch ex As Exception

        End Try

       
    End Sub


    Private Sub IlceSecim()

        DDL1_ADR_SEMT.Items.Clear()
        TB1_ADR_ZIP.Text = ""

        Try

            If (DDL1_ADR_CITY.SelectedItem.ToString() = "--Seçiniz--") Then

            Else
                DDL1_ADR_NOTE1.Items.Clear()

                citycode = DDL1_ADR_CITY.SelectedValue.ToString()
                lblcitycode.Text = citycode

                Dim dt As DataTable = New DataTable()
                DDL1_ADR_NOTE1.Items.Add(New ListItem("--Seçiniz--", "--Seçiniz--"))
                dt = ccapps.persistent.YenidenAktivasyon.IlceType(citycode)

                For Each dr2 As DataRow In dt.Rows
                    DDL1_ADR_NOTE1.Items.Add(New ListItem(dr2("DIST_DES").ToString(), dr2("DIST_COD").ToString()))
                Next
            End If
        Catch ex As Exception


        End Try

    End Sub





    Private Sub IlSecim()


        Try

            DDL1_ADR_CITY.Items.Clear()
            DDL1_ADR_CITY.Items.Add(New ListItem("--Seçiniz--", "--Seçiniz--"))
            
            Dim dt As DataTable = New DataTable()
            dt = ccapps.persistent.YenidenAktivasyon.IlType
            For Each dr2 As DataRow In dt.Rows
                DDL1_ADR_CITY.Items.Add(New ListItem(dr2("ctydes").ToString(), dr2("ctycod").ToString()))
            Next
        Catch ex As Exception

        End Try
    End Sub




    Private Sub AktivasyonReason()
        Try
            DLL_RS_CODE.Items.Clear()
            DLL_RS_CODE.Items.Add(New ListItem("--Seçiniz--", "--Seçiniz--"))
            Dim dt2 As DataTable = aktivasyonType()


            If dt2.Rows.Count > 0 Then
                For Each dr2 As DataRow In dt2.Rows
                    DLL_RS_CODE.Items.Add(New ListItem(dr2("rs_desc").ToString(), dr2("RS_ID").ToString())) 'rs_desc ve rscode Databasedeki sql variablelarının isimleri' 
                Next
            End If
        Catch ex As Exception

        End Try
       
    End Sub




    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim confirmValue As String = Request.Form("confirm_value")
        If confirmValue = "Yes" Then
            Dim now As DateTime = DateTime.Now
            Dim tarih As String = TDD_ADR_BIRTHDT.Text.Trim()
            Dim tarih2 As DateTime = Convert.ToDateTime(tarih)

            ' DateTime date1 = new DateTime(2013, 7, 22);
            Dim result As Integer = DateTime.Compare(tarih2, now) 'küçük ise -1; büyük ise 1;"
            If result = -1 Then
                Try
                    Dim nationality As Integer = Convert.ToInt32(DDL_ADR_NATIONALITY.SelectedValue)
                    Dim tc_id As String = TB_CS_TC_ID.Text.ToUpper()
                    Dim fname As String = TB_ADR_FNAME.Text.ToUpper()
                    Dim lname As String = TB_ADR_LNAME.Text.ToUpper()
                    Dim remark1 As String = TB_CS_REMARK1.Text.ToUpper()
                    Dim birth_pv As String = TB_CS_BIRTH_PROVINCE.Text.ToUpper()
                    Dim remark2 As String = TB_CS_REMARK2.Text.ToUpper()
                    Dim birth As String = TDD_ADR_BIRTHDT.Text.ToUpper()
                    Dim reg_pv As String = TB_CS_REG_PROVINCE.Text.ToUpper()
                    Dim reg_dis As String = TB_CS_REG_DISTRICT.Text.ToUpper()
                    Dim sex As String = DDL_ADR_SEX.SelectedValue.ToUpper()
                    Dim idtype As Integer = Convert.ToInt32(DDL_IDTYPE_CODE.SelectedValue)
                    Dim idno As String = TB_ADR_IDNO.Text.ToUpper()
                    Dim prgcode As String = DLL_PRG_CODE.SelectedValue.ToUpper()
                    Dim rpcode As Integer = Convert.ToInt32(DLL_RPCODE.SelectedValue)
                    Dim rscode As Integer = Convert.ToInt32(DLL_RS_CODE.SelectedValue)
                    Dim city As String = DDL1_ADR_CITY.SelectedItem.ToString().ToUpper()
                    Dim adr_note1 As String = DDL1_ADR_NOTE1.SelectedItem.ToString().ToUpper()
                    Dim street As String = ""
                    If DDL1_ADR_SEMT.SelectedValue <> "." Then
                        street = DDL1_ADR_SEMT.SelectedItem.Text.ToUpper()
                    End If

                
                    Dim zip As String = TB1_ADR_ZIP.Text.ToUpper()
                    Dim street_no As String = TB1_ADR_STREETNO.Text.ToUpper()
                    Dim pharea1 As String = TB_ADR_PHN1_AREA.Text.ToUpper()
                    Dim phone1 As String = TB_ADR_PHN1.Text.ToUpper()
                    Dim pharea2 As String = TB_ADR_PHN2_AREA.Text.ToUpper()
                    Dim phone2 As String = TB_ADR_PHN2.Text.ToUpper()
                    Dim sms As String = TB_ADR_SMSNO.Text.ToUpper()
                    Dim email As String = TB_ADR_EMAIL.Text.ToUpper()
                    Dim adr_note2 As String = TB_ADR_NOTE2.Text.ToUpper()
                    Dim mernis_status As Integer = Convert.ToInt32(lblMernisStatus.Text)

                    Dim MES As String

                    Dim res As DataTable = CreateCustomer(nationality, tc_id, fname, lname, remark1, birth_pv, remark2, birth,
                    reg_pv, reg_dis, sex, idtype, idno, prgcode, rpcode, rscode, "BUPE",
                    city, adr_note1, street, zip, street_no, pharea1, phone1, pharea2, phone2, sms, email, adr_note2, mernis_status, MES)



                    If res.Rows.Count > 0 Then
                        For Each dr2 As DataRow In res.Rows

                            If (dr2("customer_id").ToString() <> "-1") Then
                                Session("customer_id") = dr2("customer_id").ToString()
                                Session("tarife") = rpcode
                                Session("cust_type") = "bireysel"
                                Response.Redirect("HatAcilisiContractCreate.aspx", False)
                            End If




                        Next

                    End If

                Catch ex As Exception


                    Session("message") = ex.Message
                    Response.Clear()
                    Response.Status = "302 Object Moved"
                    Response.RedirectLocation = "CX_Exception.aspx"
                    Response.End()




                End Try
            Else
                Me.Page.RegisterStartupScript("javascript", "<script language=""javascript"">alert('Girilen Tarih İleri Bir Tarih Olamaz.');</script>")
            End If
        Else
            HidTable1.Visible = True

        End If
    End Sub



    Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim confirmValue As String = Request.Form("confirm_value")
        If confirmValue = "Yes" Then
            Dim now As DateTime = DateTime.Now
            Dim tarih As String = SME_TDD_ADR_BIRTHDT.Text.Trim()
            Dim tarih2 As DateTime = Convert.ToDateTime(tarih)

            ' DateTime date1 = new DateTime(2013, 7, 22);
            Dim result As Integer = DateTime.Compare(tarih2, now) 'küçük ise -1; büyük ise 1;"
            If result = -1 Then
                Try
                    Dim adr_name As String = TB_ADR_NAME.Text.ToUpper()
                    Dim adr_taxno As String = TB_ADR_TAXNO.Text.ToUpper()
                    Dim adr_compno As String = TB_ADR_COMPNO.Text.ToUpper()
                    Dim tc_id As String = SME_TB_CS_TC_ID.Text.ToUpper()
                    Dim fname As String = SME_TB_ADR_FNAME.Text.ToUpper()
                    Dim lname As String = SME_TB_ADR_LNAME.Text.ToUpper()
                    Dim remark1 As String = SME_TB_CS_REMARK1.Text.ToUpper()
                    Dim birth_pv As String = SME_TB_CS_BIRTH_PROVINCE.Text.ToUpper()
                    Dim remark2 As String = SME_TB_CS_REMARK2.Text.ToUpper()
                    Dim birth As String = SME_TDD_ADR_BIRTHDT.Text.ToUpper()
                    Dim reg_pv As String = SME_TB_CS_REG_PROVINCE.Text.ToUpper()
                    Dim reg_dis As String = SME_TB_CS_REG_DISTRICT.Text.ToUpper()
                    Dim sex As String = SME_DDL_ADR_SEX.SelectedValue.ToUpper()
                    Dim idtype As Integer = Convert.ToInt32(SME_DDL_IDTYPE_CODE.SelectedValue)
                    Dim idno As String = SME_TB_ADR_IDNO.Text.ToUpper()
                    Dim prgcode As String = SME_DLL_PRG_CODE.SelectedValue.ToUpper()
                    Dim rpcode As Integer = Convert.ToInt32(SME_DLL_RPCODE.SelectedValue)
                    Dim rscode As Integer = Convert.ToInt32(SME_DLL_RS_CODE.SelectedValue)
                    Dim city As String = SME_DDL1_ADR_CITY.SelectedItem.ToString().ToUpper()
                    Dim adr_note1 As String = SME_DDL1_ADR_NOTE1.SelectedItem.ToString().ToUpper()
                    Dim street As String = ""
                    If SME_DDL1_ADR_SEMT.SelectedValue <> "." Then
                        street = SME_DDL1_ADR_SEMT.SelectedItem.Text.ToString.ToUpper()
                    End If
                    SME_DDL1_ADR_SEMT.SelectedItem.Text.ToUpper()
                    Dim zip As String = SME_TB1_ADR_ZIP.Text.ToUpper()
                    Dim street_no As String = SME_TB1_ADR_STREETNO.Text.ToUpper()
                    Dim pharea1 As String = SME_TB_ADR_PHN1_AREA.Text.ToUpper()
                    Dim phone1 As String = SME_TB_ADR_PHN1.Text.ToUpper()
                    Dim pharea2 As String = SME_TB_ADR_PHN2_AREA.Text.ToUpper()
                    Dim phone2 As String = SME_TB_ADR_PHN2.Text.ToUpper()
                    Dim sms As String = SME_TB_ADR_SMSNO.Text.ToUpper()
                    Dim email As String = SME_TB_ADR_EMAIL.Text.ToUpper()
                    Dim adr_note2 As String = SME_TB_ADR_NOTE2.Text.ToUpper()
                    Dim mernis_status As Integer = Convert.ToInt32(lblMernisStatus.Text)


                    Dim MES As String

                    Dim res As DataTable = CreateCustomerSME(adr_name, adr_taxno, adr_compno, tc_id, fname, lname, remark1, birth_pv, remark2, birth,
                    reg_pv, reg_dis, sex, idtype, idno, prgcode, rpcode, rscode, "BUPE",
                    city, adr_note1, street, zip, street_no, pharea1, phone1, pharea2, phone2, sms, email, adr_note2, mernis_status, MES)







                    If res.Rows.Count > 0 Then
                        For Each dr2 As DataRow In res.Rows

                            If (dr2("customer_id").ToString() <> "-1") Then
                                Session("customer_id") = dr2("customer_id").ToString()
                                Session("tarife") = rpcode
                                Response.Redirect("HatAcilisiContractCreate.aspx", False)
                            End If

                            LblError.Text = "İşleminizde Hata Oluşmuşur. Lütfen Tekrar Deneyiniz"


                        Next

                    End If

                Catch ex As Exception


                    Session("message") = ex.Message
                    Response.Clear()
                    Response.Status = "302 Object Moved"
                    Response.RedirectLocation = "CX_Exception.aspx"
                    Response.End()




                End Try
            Else
                Me.Page.RegisterStartupScript("javascript", "<script language=""javascript"">alert('Girilen Tarih İleri Bir Tarih Olamaz.');</script>")
            End If
        Else
            hidTable2.Visible = True

        End If
    End Sub



    Protected Sub DLL_PRG_CODE_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DLL_PRG_CODE.SelectedIndexChanged
        HidTable1.Visible = True
        TarifeSecim()
    End Sub

    Protected Sub DDL1_ADR_CITY_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DDL1_ADR_CITY.SelectedIndexChanged
        HidTable1.Visible = True
        IlceSecim()
    End Sub

    Protected Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        Dim confirmValue As String = Request.Form("confirm_value")
        If confirmValue = "Yes" Then
            Dim now As DateTime = DateTime.Now
            Dim tarih As String = TOP_TDD_ADR_BIRTHDT.Text.Trim()
            Dim tarih2 As DateTime = Convert.ToDateTime(tarih)

            ' DateTime date1 = new DateTime(2013, 7, 22);
            Dim result As Integer = DateTime.Compare(tarih2, now) 'küçük ise -1; büyük ise 1;"
            If result = -1 Then
                Try

                    Dim adr_name As String = TOP_TB_ADR_NAME.Text.ToUpper()
                    Dim adr_taxno As String = TOP_TB_ADR_TAXNO.Text.ToUpper()
                    Dim adr_compno As String = TOP_TB_ADR_COMPNO.Text.ToUpper()
                    Dim fname As String = TOP_TB_ADR_FNAME.Text.ToUpper()
                    Dim lname As String = TOP_TB_ADR_LNAME.Text.ToUpper()
                    Dim remark1 As String = TOP_TB_CS_REMARK1.Text.ToUpper()
                    Dim birth_pv As String = TOP_TB_CS_BIRTH_PROVINCE.Text.ToUpper()
                    Dim remark2 As String = TOP_TB_CS_REMARK2.Text.ToUpper()
                    Dim birth As String = TOP_TDD_ADR_BIRTHDT.Text.ToUpper()
                    Dim reg_pv As String = TOP_TB_CS_REG_PROVINCE.Text.ToUpper()
                    Dim reg_dis As String = TOP_TB_CS_REG_DISTRICT.Text.ToUpper()
                    Dim sex As String = TOP_DDL_ADR_SEX.SelectedValue.ToUpper()
                    Dim idtype As Integer = Convert.ToInt32(TOP_DDL_IDTYPE_CODE.SelectedValue)
                    Dim idno As String = TOP_TB_ADR_IDNO.Text.ToUpper()
                    Dim prgcode As String = TOP_DLL_PRG_CODE.SelectedValue.ToUpper()
                    Dim rpcode As Integer = Convert.ToInt32(TOP_DLL_RPCODE.SelectedValue)
                    Dim rscode As Integer = Convert.ToInt32(TOP_DLL_RS_CODE.SelectedValue)
                    Dim city As String = TOP_DDL1_ADR_CITY.SelectedItem.ToString().ToUpper()
                    Dim adr_note1 As String = TOP_DDL1_ADR_NOTE1.SelectedItem.ToString().ToUpper()


                    Dim street As String = ""
                    If TOP_DDL1_ADR_SEMT.SelectedItem.Value <> "." Then
                        street = TOP_DDL1_ADR_SEMT.SelectedItem.Text.ToUpper()
                    End If


                    Dim zip As String = TOP_TB1_ADR_ZIP.Text.ToUpper()
                    Dim street_no As String = TOP_TB1_ADR_STREETNO.Text.ToUpper()
                    Dim pharea1 As String = TOP_TB_ADR_PHN1_AREA.Text.ToUpper()
                    Dim phone1 As String = TOP_TB_ADR_PHN1.Text.ToUpper()
                    Dim pharea2 As String = TOP_TB_ADR_PHN2_AREA.Text.ToUpper()
                    Dim phone2 As String = TOP_TB_ADR_PHN2.Text.ToUpper()
                    Dim sms As String = TOP_TB_ADR_SMSNO.Text.ToUpper()
                    Dim email As String = TOP_TB_ADR_EMAIL.Text.ToUpper()
                    Dim adr_note2 As String = TOP_TB1_ADR_NOTE2.Text.ToUpper()

                    Dim MES As String

                    Dim res As DataTable = CreateCustomerLATop(adr_name, adr_taxno, adr_compno, fname, lname, remark1, birth_pv, remark2, birth,
                    reg_pv, reg_dis, sex, idtype, idno, prgcode, rpcode, rscode, "BUPE",
                    city, adr_note1, street, zip, street_no, pharea1, phone1, pharea2, phone2, sms, email, adr_note2, MES)

                    'Label1.Text = res(0).ToString() ' Yeni Oluşturulan Customer Id'nin Billing Net Görüntülenmesi






                    If res.Rows.Count > 0 Then
                        For Each dr2 As DataRow In res.Rows

                            If (dr2("customer_id").ToString() <> "-1") Then
                                Session("LATop") = 1
                                Label1.Text = dr2("customer_id").ToString()
                                Session("customer_id") = dr2("customer_id").ToString()
                                Session("tarife") = rpcode
                                Response.Redirect("HatAcilisiSummary.aspx", False)
                            End If

                            LblError.Text = "İşleminizde Hata Oluşmuşur. Lütfen Tekrar Deneyiniz"


                        Next

                    End If
                Catch ex As Exception


                    Session("message") = ex.Message
                    Response.Clear()
                    Response.Status = "302 Object Moved"
                    Response.RedirectLocation = "CX_Exception.aspx"
                    Response.End()




                End Try
            Else
                Me.Page.RegisterStartupScript("javascript", "<script language=""javascript"">alert('Girilen Tarih İleri Bir Tarih Olamaz.');</script>")
            End If
        Else
            YeniTable.Visible = True

        End If
    End Sub

    Private Sub TarifeSecimLATop()
        Try
            TOP_DLL_RPCODE.Items.Clear()
            TOP_DLL_RPCODE.Items.Add(New ListItem("--Seçiniz--", "--Seçiniz--"))
            TOP_DLL_RPCODE.Items.Clear()
            If (TOP_DLL_PRG_CODE.SelectedItem.ToString() = "--Seçiniz--") Then

            Else
                TOP_DLL_RPCODE.Items.Clear()
                Dim musteri_code As Integer = TOP_DLL_PRG_CODE.SelectedValue



                Dim dt3 As DataTable = TarifeTypeLA(musteri_code)

                If dt3.Rows.Count > 0 Then
                    For Each dr3 As DataRow In dt3.Rows
                        TOP_DLL_RPCODE.Items.Add(New ListItem(dr3("des").ToString(), dr3("tmcode").ToString()))

                    Next
                End If

            End If
        Catch ex As Exception

        End Try
        




    End Sub


    Private Sub KimlikSecimLATop()

        TOP_DDL_IDTYPE_CODE.Items.Clear()
        TOP_DDL_IDTYPE_CODE.Items.Add(New ListItem("--Seçiniz--", "--Seçiniz--"))
        Dim dt As DataTable = KimlikType()

        If dt.Rows.Count > 0 Then
            For Each dr As DataRow In dt.Rows
                TOP_DDL_IDTYPE_CODE.Items.Add(New ListItem(dr("IDTYPE_NAME").ToString(), dr("IDTYPE_CODE").ToString()))
            Next
        End If
    End Sub

    Private Sub MusteriGrubuLATop()

        TOP_DLL_PRG_CODE.Items.Clear()
        TOP_DLL_PRG_CODE.Items.Add(New ListItem("--Seçiniz--", "--Seçiniz--"))
        Dim dt As DataTable = TanimsizgetcustomertypeLA()

        If dt.Rows.Count > 0 Then
            For Each dr As DataRow In dt.Rows
                TOP_DLL_PRG_CODE.Items.Add(New ListItem(dr("prgname").ToString(), dr("prgcode").ToString()))
            Next
        End If
    End Sub




    Private Sub IlceSecimLATop()
        TOP_DDL1_ADR_SEMT.Items.Clear()
        TOP_TB1_ADR_ZIP.Text = ""


        Try

            If (TOP_DDL1_ADR_CITY.SelectedItem.ToString() = "--Seçiniz--") Then

            Else
                TOP_DDL1_ADR_NOTE1.Items.Clear()
                Dim citycode As String = TOP_DDL1_ADR_CITY.SelectedValue.ToString()
                lblcitycode.Text = citycode

                Dim dt As DataTable = New DataTable()
                TOP_DDL1_ADR_NOTE1.Items.Add(New ListItem("--Seçiniz--", "--Seçiniz--"))
                dt = ccapps.persistent.YenidenAktivasyon.IlceType(citycode)

                TOP_DDL1_ADR_NOTE1.Items.Clear()


                TOP_DDL1_ADR_NOTE1.Items.Add(New ListItem("--Seçiniz--", "--Seçiniz--"))
                For Each dr2 As DataRow In dt.Rows

                    TOP_DDL1_ADR_NOTE1.Items.Add(New ListItem(dr2("DIST_DES").ToString(), dr2("DIST_COD").ToString()))
                Next
            End If
        Catch ex As Exception


        End Try

        'If (TOP_DDL1_ADR_CITY.SelectedItem.ToString() = "--Seçiniz--") Then

        'Else
        '    TOP_DDL1_ADR_NOTE1.Items.Clear()
        '    Dim citycode As Integer = TOP_DDL1_ADR_CITY.SelectedValue



        '    Dim dt3 As DataTable = IlceType(citycode)

        '    If dt3.Rows.Count > 0 Then
        '        For Each dr3 As DataRow In dt3.Rows
        '            TOP_DDL1_ADR_NOTE1.Items.Add(New ListItem(dr3("DIST_DES").ToString(), dr3("DIST_COD").ToString()))

        '        Next
        '    End If
        'End If
     
    End Sub





    Private Sub IlSecimLATop()
        Try


            TOP_DDL1_ADR_CITY.Items.Clear()
            TOP_DDL1_ADR_CITY.Items.Add(New ListItem("--Seçiniz--", "--Seçiniz--"))
            Dim dt As DataTable = New DataTable()
            dt = ccapps.persistent.YenidenAktivasyon.IlType
            For Each dr2 As DataRow In dt.Rows
                TOP_DDL1_ADR_CITY.Items.Add(New ListItem(dr2("ctydes").ToString(), dr2("ctycod").ToString()))
            Next
        Catch ex As Exception

        End Try
       

       
    End Sub

    Private Sub Clear()
        TB_ADR_FNAME.Text = ""
        TB_ADR_LNAME.Text = ""
        TB_CS_BIRTH_PROVINCE.Text = ""
        TB_CS_TC_ID.Text = ""
        TDD_ADR_BIRTHDT.Text = ""
        TB_CS_REMARK1.Text = ""
        TB_CS_REMARK2.Text = ""
        DLL_RPCODE.Items.Clear()
        DLL_PRG_CODE.Items.Clear()
        DDL1_ADR_NOTE1.Items.Clear()
        SME_DLL_RPCODE.Items.Clear()
        SME_DDL1_ADR_NOTE1.Items.Clear()
        SME_DLL_PRG_CODE.Items.Clear()
        DDL_ADR_SEX.SelectedValue = "--Seçiniz--"
        SME_DDL_ADR_SEX.SelectedValue = "--Seçiniz--"
        DLL_RPCODE.Items.Add(New ListItem("--Seçiniz--", "--Seçiniz--"))
        DLL_RPCODE.SelectedValue = "--Seçiniz--"
        DLL_PRG_CODE.Items.Add(New ListItem("--Seçiniz--", "--Seçiniz--"))
        DLL_PRG_CODE.SelectedValue = "--Seçiniz--"
        DDL1_ADR_NOTE1.Items.Add(New ListItem("--Seçiniz--", "--Seçiniz--"))
        DDL1_ADR_NOTE1.SelectedValue = "--Seçiniz--"
        SME_DLL_RPCODE.Items.Add(New ListItem("--Seçiniz--", "--Seçiniz--"))
        SME_DLL_RPCODE.SelectedValue = "--Seçiniz--"
        SME_DDL1_ADR_NOTE1.Items.Add(New ListItem("--Seçiniz--", "--Seçiniz--"))
        SME_DDL1_ADR_NOTE1.SelectedValue = "--Seçiniz--"
        SME_DLL_PRG_CODE.Items.Add(New ListItem("--Seçiniz--", "--Seçiniz--"))
        SME_DLL_PRG_CODE.SelectedValue = "--Seçiniz--"
        TB_CS_REG_PROVINCE.Text = ""
        TB_CS_REG_DISTRICT.Text = ""
        TB_ADR_IDNO.Text = ""
        TB1_ADR_STREETNO.Text = ""
        TB_ADR_NOTE2.Text = ""
        'TB1_ADR_STREET.Text = ""
        TB1_ADR_ZIP.Text = ""
        TB_ADR_PHN1_AREA.Text = ""
        TB_ADR_PHN1.Text = ""
        TB_ADR_PHN2_AREA.Text = ""
        TB_ADR_PHN2.Text = ""
        TB_ADR_SMSNO.Text = ""
        TB_ADR_EMAIL.Text = ""
        lblTcIdControlError.Text = ""
        TB_ADR_TAXNO.Text = ""
        TB_ADR_COMPNO.Text = ""
        TB_ADR_NAME.Text = ""
        SME_TB_CS_TC_ID.Text = ""
        Label4.Text = ""
        SME_TB_ADR_FNAME.Text = ""
        SME_TDD_ADR_BIRTHDT.Text = ""
        SME_TB_CS_REMARK1.Text = ""
        SME_TB_ADR_LNAME.Text = ""
        SME_TB_CS_REG_PROVINCE.Text = ""
        SME_TB_CS_BIRTH_PROVINCE.Text = ""
        SME_TB_CS_REG_DISTRICT.Text = ""
        SME_TB_CS_REMARK2.Text = ""
        SME_TB_ADR_IDNO.Text = ""
        SME_TB1_ADR_STREETNO.Text = ""
        SME_TB_ADR_NOTE2.Text = ""
        SME_TB1_ADR_ZIP.Text = ""
        SME_TB_ADR_PHN1_AREA.Text = ""
        SME_TB_ADR_PHN1.Text = ""
        SME_TB_ADR_PHN2_AREA.Text = ""
        SME_TB_ADR_PHN2.Text = ""
        SME_TB_ADR_SMSNO.Text = ""
        SME_TB_ADR_EMAIL.Text = ""





        TOP_TB1_ADR_ZIP.Text = ""
        TOP_TB_ADR_PHN1_AREA.Text = ""
        TOP_TB_ADR_PHN1.Text = ""
        TOP_TB_ADR_PHN2_AREA.Text = ""
        TOP_TB_ADR_PHN2.Text = ""
        TOP_TB_ADR_SMSNO.Text = ""
        TOP_TB_ADR_EMAIL.Text = ""
        TOP_TB_ADR_TAXNO.Text = ""
        TOP_TB_ADR_COMPNO.Text = ""
        TOP_TB_ADR_NAME.Text = ""
        Label4.Text = ""
        TOP_TB_ADR_FNAME.Text = ""
        TOP_TDD_ADR_BIRTHDT.Text = ""
        TOP_TB_CS_REMARK1.Text = ""
        TOP_TB_ADR_LNAME.Text = ""
        TOP_TB_CS_REG_PROVINCE.Text = ""
        TOP_TB_CS_BIRTH_PROVINCE.Text = ""
        TOP_TB_CS_REG_DISTRICT.Text = ""
        TOP_TB_CS_REMARK2.Text = ""
        TOP_TB_ADR_IDNO.Text = ""
        TOP_TB1_ADR_STREETNO.Text = ""
        TOP_TB1_ADR_NOTE2.Text = ""
        TOP_TB1_ADR_ZIP.Text = ""
        TOP_TB_ADR_PHN1_AREA.Text = ""
        TOP_TB_ADR_PHN1.Text = ""
        TOP_TB_ADR_PHN2_AREA.Text = ""
        TOP_TB_ADR_PHN2.Text = ""
        TOP_TB_ADR_SMSNO.Text = ""
        TOP_TB_ADR_EMAIL.Text = ""


        TOP_DDL_ADR_SEX.SelectedValue = "--Seçiniz--"
        SUB_DDL_ADR_SEX.SelectedValue = "--Seçiniz--"

        TOP_DLL_PRG_CODE.Items.Add(New ListItem("--Seçiniz--", "--Seçiniz--"))
        TOP_DLL_RPCODE.Items.Add(New ListItem("--Seçiniz--", "--Seçiniz--"))
        TOP_DLL_RPCODE.SelectedValue = "--Seçiniz--"
        TOP_DLL_PRG_CODE.Items.Add(New ListItem("--Seçiniz--", "--Seçiniz--"))
        TOP_DLL_PRG_CODE.SelectedValue = "--Seçiniz--"
        TOP_DDL1_ADR_NOTE1.Items.Add(New ListItem("--Seçiniz--", "--Seçiniz--"))
        TOP_DDL1_ADR_NOTE1.SelectedValue = "--Seçiniz--"

       



        SUB_TB1_ADR_ZIP.Text = ""
        SUB_TB_ADR_PHN1_AREA.Text = ""
        SUB_TB_ADR_PHN1.Text = ""
        SUB_TB_ADR_PHN2_AREA.Text = ""
        SUB_TB_ADR_PHN2.Text = ""
        SUB_TB_ADR_SMSNO.Text = ""
        SUB_TB_ADR_EMAIL.Text = ""
        SUB_TB_ADR_TAXNO.Text = ""
        SUB_TB_ADR_COMPNO.Text = ""
        SUB_TB_ADR_NAME.Text = ""
        Label4.Text = ""
        SUB_TB_ADR_FNAME.Text = ""
        SUB_TDD_ADR_BIRTHDT.Text = ""
        SUB_TB_CS_REMARK1.Text = ""
        SUB_TB_ADR_LNAME.Text = ""
        SUB_TB_CS_REG_PROVINCE.Text = ""
        SUB_TB_CS_BIRTH_PROVINCE.Text = ""
        SUB_TB_CS_REG_DISTRICT.Text = ""
        SUB_TB_CS_REMARK2.Text = ""
        SUB_TB_ADR_IDNO.Text = ""
        SUB_TB1_ADR_STREETNO.Text = ""
        SUB_TB_ADR_NOTE2.Text = ""
        SUB_TB1_ADR_ZIP.Text = ""
        SUB_TB_ADR_PHN1_AREA.Text = ""
        SUB_TB_ADR_PHN1.Text = ""
        SUB_TB_ADR_PHN2_AREA.Text = ""
        SUB_TB_ADR_PHN2.Text = ""
        SUB_TB_ADR_SMSNO.Text = ""
        SUB_TB_ADR_EMAIL.Text = ""

        TB_CS_TC_ID.Enabled = True
        btnTCIDDogrulama.Enabled = True
        btnTCIDDogrulama0.Enabled = True
        SME_TB_CS_TC_ID.Enabled = True
        Button1.Enabled = True
        Button8.Enabled = True
        Button2.Enabled = True


        LblBLGLControl.Text = ""
        LblGLBLControl.Text = ""
        LblError.Text = ""
        MevcutAd.Text = ""
        MevcutCustomer_id.Text = ""
        MevcutSicil.Text = ""
        Mevcut_TB_CSCOMPTAXNO.Text = ""
        TB_CustCode2.Text = ""

        Session("durum") = ""
        Session("customer_id") = ""


        SUB_DDL1_ADR_NOTE1.Items.Clear()
        SUB_DDL1_ADR_NOTE1.Items.Add(New ListItem("--Seçiniz--", "--Seçiniz--"))
        SUB_DDL1_ADR_NOTE1.SelectedValue = "--Seçiniz--"

    End Sub


    Private Sub AktivasyonReasonLATop()
        TOP_DLL_RS_CODE.Items.Clear()
        TOP_DLL_RS_CODE.Items.Add(New ListItem("--Seçiniz--", "--Seçiniz--"))
        Dim dt2 As DataTable = aktivasyonType()


        If dt2.Rows.Count > 0 Then
            For Each dr2 As DataRow In dt2.Rows
                TOP_DLL_RS_CODE.Items.Add(New ListItem(dr2("rs_desc").ToString(), dr2("RS_ID").ToString())) 'rs_desc ve rscode Databasedeki sql variablelarının isimleri' 
            Next
        End If
    End Sub


    Protected Sub TOP_DLL_PRG_CODE_SelectedIndexChanged(sender As Object, e As EventArgs) Handles TOP_DLL_PRG_CODE.SelectedIndexChanged
        hidTable3.Visible = True
        YeniTable.Visible = True
        TarifeSecimLATop()
    End Sub

    Protected Sub TOP_DDL1_ADR_CITY_SelectedIndexChanged(sender As Object, e As EventArgs) Handles TOP_DDL1_ADR_CITY.SelectedIndexChanged
        hidTable3.Visible = True
        YeniTable.Visible = True
        IlceSecimLATop()
    End Sub

    Protected Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        Dim gen As String = ""
        Clear()
        Try

            CustcodeSearch()
            SubLevel.Visible = False
        Catch ex As Exception
            'Response.Write(ex.ToString())
            hidTable3.Visible = True
            MevcutTable.Visible = True
            SubLevel.Visible = False

        End Try
    End Sub
    Private Sub CustcodeSearch()


        Dim custcode As String = TB_CustCode.Text.Trim()
        Dim dt1 As DataTable = GetCustomerLevelWithCustcode(custcode)
        Dim customer_level As String

        If dt1.Rows.Count > 0 Then
            For Each dr1 As DataRow In dt1.Rows
                customer_level = (dr1("cslevel").ToString())
            Next
        End If

        If customer_level <> "30" Then
            ErrorMessage.Visible = False
            ErrorMessage.Text = ""

            Dim dt2 As DataTable = LASubCustCodeSearch(custcode)

            Dim gen As String

            If dt2.Rows.Count > 0 Then
                For Each dr2 As DataRow In dt2.Rows

                    LB_ADR_FLNAME.Text = dr2("ccfname").ToString() + dr2("cclname").ToString() + "," + dr2("CCCITY").ToString()
                    LB_ADR_NAME.Text = dr2("ccname").ToString()
                    LB_TB_ADR_TAXNO.Text = dr2("CSCOMPTAXNO").ToString()
                    gen = dr2("CUSTOMER_ID").ToString()
                    hid.Text = gen

                    hidTable3.Visible = True
                    MevcutTable.Visible = True
                    ErrorMessage.Visible = False
                    Button6.Enabled = True

                Next


            Else
                hidTable3.Visible = True
                MevcutTable.Visible = True
                ErrorMessage.Visible = True
                Button6.Enabled = False

            End If

        Else
            hidTable3.Visible = True
            MevcutTable.Visible = True
            ErrorMessage.Visible = True
            ErrorMessage.Text = "Customer Level 30 oldugu için işlem gerçekleştirilememektedir."
            Button6.Enabled = False
        End If


    End Sub


    Protected Sub SUB_DDL1_ADR_CITY_SelectedIndexChanged(sender As Object, e As EventArgs) Handles SUB_DDL1_ADR_CITY.SelectedIndexChanged
        hidTable3.Visible = True
        MevcutTable.Visible = True
        SubLevel.Visible = True
        IlceSecimLASub()
    End Sub

    Protected Sub SUB_DLL_PRG_CODE_SelectedIndexChanged(sender As Object, e As EventArgs) Handles SUB_DLL_PRG_CODE.SelectedIndexChanged
        hidTable3.Visible = True
        MevcutTable.Visible = True
        SubLevel.Visible = True
        TarifeSecimLASub()
    End Sub

    Protected Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
        SubLevel.Visible = True
        Dim confirmValue As String = Request.Form("confirm_value")
        SubLevel.Visible = True
        If confirmValue = "Yes" Then
            Dim now As DateTime = DateTime.Now
            Dim tarih As String = SUB_TDD_ADR_BIRTHDT.Text.Trim()
            Dim tarih2 As DateTime = Convert.ToDateTime(tarih)

            ' DateTime date1 = new DateTime(2013, 7, 22);
            Dim result As Integer = DateTime.Compare(tarih2, now) 'küçük ise -1; büyük ise 1;"
            If result = -1 Then
                Try

                    Dim search_customerid As Integer = Convert.ToInt32(hid.Text)
                    Dim dt2 As DataTable = GetLALevel(search_customerid)
                    Dim customer_level As String

                    If dt2.Rows.Count > 0 Then
                        For Each dr2 As DataRow In dt2.Rows
                            customer_level = (dr2("cslevel").ToString())
                        Next
                    End If

                    Select Case customer_level
                        Case "10"
                            customer_level = "20"
                        Case "20"
                            customer_level = "30"
                        Case "30"
                            customer_level = "40"

                    End Select


                    Dim adr_name As String = SUB_TB_ADR_NAME.Text.ToUpper()
                    Dim adr_taxno As String = SUB_TB_ADR_TAXNO.Text.ToUpper()
                    Dim adr_compno As String = SUB_TB_ADR_COMPNO.Text.ToUpper()
                    Dim fname As String = SUB_TB_ADR_FNAME.Text.ToUpper()
                    Dim lname As String = SUB_TB_ADR_LNAME.Text.ToUpper()
                    Dim remark1 As String = SUB_TB_CS_REMARK1.Text.ToUpper()
                    Dim birth_pv As String = SUB_TB_CS_BIRTH_PROVINCE.Text.ToUpper()
                    Dim remark2 As String = SUB_TB_CS_REMARK2.Text.ToUpper()
                    Dim birth As String = SUB_TDD_ADR_BIRTHDT.Text.ToUpper()
                    Dim reg_pv As String = SUB_TB_CS_REG_PROVINCE.Text.ToUpper()
                    Dim reg_dis As String = SUB_TB_CS_REG_DISTRICT.Text.ToUpper()
                    Dim sex As String = SUB_DDL_ADR_SEX.SelectedValue.ToUpper()
                    Dim idtype As Integer = Convert.ToInt32(SUB_DDL_IDTYPE_CODE.SelectedValue)
                    Dim idno As String = SUB_TB_ADR_IDNO.Text.ToUpper()
                    Dim prgcode As String = SUB_DLL_PRG_CODE.SelectedValue.ToUpper()
                    Dim rpcode As Integer = Convert.ToInt32(SUB_DLL_RPCODE.SelectedValue)
                    Dim rscode As Integer = Convert.ToInt32(SUB_DLL_RS_CODE.SelectedValue)
                    Dim city As String = SUB_DDL1_ADR_CITY.SelectedItem.ToString().ToUpper()
                    Dim adr_note1 As String = SUB_DDL1_ADR_NOTE1.SelectedItem.ToString().ToUpper()
                    Dim street As String = ""
                    If SUB_DDL1_ADR_SEMT.SelectedItem.Value <> "" Then
                        street = SUB_DDL1_ADR_SEMT.SelectedItem.Text.ToUpper()
                    End If


                    Dim zip As String = SUB_TB1_ADR_ZIP.Text.ToUpper()
                    Dim street_no As String = SUB_TB1_ADR_STREETNO.Text.ToUpper()
                    Dim pharea1 As String = SUB_TB_ADR_PHN1_AREA.Text.ToUpper()
                    Dim phone1 As String = SUB_TB_ADR_PHN1.Text.ToUpper()
                    Dim pharea2 As String = SUB_TB_ADR_PHN2_AREA.Text.ToUpper()
                    Dim phone2 As String = SUB_TB_ADR_PHN2.Text.ToUpper()
                    Dim sms As String = SUB_TB_ADR_SMSNO.Text.ToUpper()
                    Dim email As String = SUB_TB_ADR_EMAIL.Text.ToUpper()
                    Dim adr_note2 As String = SUB_TB_ADR_NOTE2.Text.ToUpper()

                    Dim MES As String

                    Dim res As DataTable = CreateCustomerLASub(search_customerid, customer_level, adr_name, adr_taxno, adr_compno, fname, lname, remark1, birth_pv, remark2, birth,
                    reg_pv, reg_dis, sex, idtype, idno, prgcode, rpcode, rscode, "BUPE",
                    city, adr_note1, street, zip, street_no, pharea1, phone1, pharea2, phone2, sms, email, adr_note2, MES)

                    'Label1.Text = res(0).ToString() ' Yeni Oluşturulan Customer Id'nin Billing Net Görüntülenmesi




                    If res.Rows.Count > 0 Then
                        For Each dr2 As DataRow In res.Rows

                            If (dr2("customer_id").ToString() <> "-1") Then
                                Session("LATop") = 1
                                Label1.Text = dr2("customer_id").ToString()
                                Session("customer_id") = dr2("customer_id").ToString()
                                Session("tarife") = rpcode
                                Response.Redirect("HatAcilisiSummary.aspx", False)

                            End If

                            If dr2("customer_id").ToString() = "-1" Then
                                LblError.Text = "Eklediğiniz cc’lar max. Sınıra ulaşmıştır(99 adet). Lütfen yeni bir cc oluşturunuz."
                            Else
                                LblError.Text = "İşleminizde Hata Oluşmuşur. Lütfen Tekrar Deneyiniz"
                            End If




                        Next

                    End If
                Catch ex As Exception


                    Session("message") = ex.Message
                    Response.Clear()
                    Response.Status = "302 Object Moved"
                    Response.RedirectLocation = "CX_Exception.aspx"
                    Response.End()




                End Try
            Else
                Me.Page.RegisterStartupScript("javascript", "<script language=""javascript"">alert('Girilen Tarih İleri Bir Tarih Olamaz.');</script>")
            End If
        Else
            SubLevel.Visible = True

        End If
    End Sub



    Protected Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
        hidTable3.Visible = True
        SubLevel.Visible = True
        MevcutTable.Visible = True
        SUB_DDL1_ADR_NOTE1.Enabled = True
        SUB_DDL1_ADR_CITY.Enabled = True
        SUB_DDL1_ADR_NOTE1.Items.Clear()
        SUB_DDL1_ADR_CITY.Items.Clear()
        IlSecimLASub()
        IlceSecimLASub()

    End Sub

    Protected Sub DDL_ADR_NATIONALITY_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DDL_ADR_NATIONALITY.SelectedIndexChanged
        HidTable1.Visible = True


        If (DDL_ADR_NATIONALITY.SelectedValue = 2) Then
            TB_CS_TC_ID.Enabled = True
            btnTCIDDogrulama.Visible = True
            btnTCIDDogrulama.Enabled = True
            TB_CS_TC_ID.Visible = True
            HidTable1.Visible = True
            RequiredFieldValidator1.Enabled = True
        End If

        If (DDL_ADR_NATIONALITY.SelectedValue <> 2) Then
            btnTCIDDogrulama.Enabled = False
            btnTCIDDogrulama.Visible = True
            TB_CS_TC_ID.Enabled = False
            TB_CS_TC_ID.Visible = True
            TB_CS_TC_ID.Text = ""
            RequiredFieldValidator1.Enabled = False
            LblBLGLControl.Text = ""
            lblTcIdControlError.Text = ""
            Button1.Enabled = True
        End If

    End Sub

    Protected Sub btnTCIDDogrulama_Click(sender As Object, e As EventArgs) Handles btnTCIDDogrulama.Click
        HidTable1.Visible = True
        If TB_CS_TC_ID.Text = "" Then

            Me.Page.RegisterStartupScript("javascript", "<script language=""javascript"">alert('TC No Alanı Boş Değer İçermez.');</script>")

        Else

            Try

                Dim d As Double = Double.Parse(TB_CS_TC_ID.Text)

                If TB_CS_TC_ID.Text.Length = 11 Then

                    Dim name, surname, gender, fatherName, birthDay, birthMonth, birthYear, cityName, countyName, anneKizlikSoyad, birthPlace As String

                    If (persistent.ChangeSIMpersistence.CheckMernisStatus2(TB_CS_TC_ID.Text, name, surname, gender, fatherName, birthDay, birthMonth, birthYear, cityName, countyName, anneKizlikSoyad, birthPlace) = "0") Then


                        lblTcIdControlError.Text = "Geçerli TC No"
                        TB_ADR_FNAME.Text = NullControl(name)
                        TB_ADR_LNAME.Text = NullControl(surname)
                        TB_CS_REMARK1.Text = NullControl(fatherName)
                        TB_CS_REMARK2.Text = NullControl(anneKizlikSoyad)
                        TB_CS_BIRTH_PROVINCE.Text = NullControl(birthPlace)
                        TB_CS_REG_PROVINCE.Text = NullControl(cityName)
                        TB_CS_REG_DISTRICT.Text = NullControl(countyName)

                        If birthDay.Length = 1 Then
                            birthDay = "0" + birthDay
                        End If
                        If birthMonth.Length = 1 Then
                            birthMonth = "0" + birthMonth
                        End If
                        TDD_ADR_BIRTHDT.Text = birthDay + "." + birthMonth + "." + birthYear

                        If gender = "Erkek" Then
                            DDL_ADR_SEX.SelectedIndex = 1
                        ElseIf gender = "Kadın" Then
                            DDL_ADR_SEX.SelectedIndex = 2
                        Else
                            DDL_ADR_SEX.SelectedIndex = 0
                        End If
                        lblMernisStatus.Text = 1

                        LblBLGLControl.Text = persistent.ChangeSIMpersistence.CheckSingleIwisResult(TB_CS_TC_ID.Text)
                        If LblBLGLControl.Text = "OK" Then
                            Button1.Enabled = True
                        Else
                            Button1.Enabled = False
                        End If



                    Else

                        lblTcIdControlError.Text = "TC No geçerli değildir Lütfen tekrar deneyiniz"
                        lblMernisStatus.Text = 2

                        Me.Page.RegisterStartupScript("javascript", "<script language=""javascript"">alert('TC No geçerli değildir Lütfen tekrar deneyiniz');</script>")

                    End If

                Else

                    lblTcIdControlError.Text = "TC No Alanı 11 Karakter Olmalıdır."

                    Me.Page.RegisterStartupScript("javascript", "<script language=""javascript"">alert('TC No Alanı 11 Karakter Olmalıdır');</script>")




                End If

            Catch ex As Exception

                Me.Page.RegisterStartupScript("javascript", "<script language=""javascript"">alert('TC No Alanı Harf İçermez.');</script>")

            End Try



        End If


    End Sub

    Public Shared Function TcControl(ByVal tc As String) As String
        Dim d As Double = Double.Parse(tc)
        Dim tcnumber As String = ""

        tcnumber = persistent.ChangeSIMpersistence.CheckSingleIwisResult(tc)

        If tcnumber = "OK" Then
            Return ""
        Else
            Return tcnumber
        End If



    End Function


    Protected Sub VergiSicilNoGetir(sender As Object, e As EventArgs) Handles Button11.Click
        i = 2
        VergiSicil()
        MevcutTable.Visible = True
        HidTable1.Visible = False
        KurumsalTable.Visible = True
    End Sub

    Private Sub VergiSicil()
        Try
            LblError.Text = ""
            Dim sicilno As String = Mevcut_TB_CSCOMPTAXNO.Text

            Dim dt2 As DataTable = SMEVergiSearch(sicilno)


            If dt2.Rows.Count > 0 Then
                For Each dr2 As DataRow In dt2.Rows

                    MevcutAd.Text = dr2("ccfname").ToString() + "     " + dr2("cclname").ToString() + "," + dr2("CCCITY").ToString()
                    MevcutCustomer_id.Text = dr2("CUSTOMER_ID").ToString()
                    MevcutSicil.Text = Mevcut_TB_CSCOMPTAXNO.Text
                    LblTcid.Text = dr2("CSTCIDNUMBER").ToString()
                    Button8.Enabled = True
                    ErrorMessage.Text = ""

                Next
                If LblTcid.Text = "" Then
                    Button8.Enabled = True
                Else
                    LblError.Text = TcControl(LblTcid.Text)
                    If LblError.Text <> "" Then
                        Button8.Enabled = False
                    Else
                        Button8.Enabled = True
                    End If


                End If


            Else
                Button8.Enabled = False
                ErrorMessage.Text = "Girmiş olduğunuz custcode için veri yoktur"
                If sicilno = "" Then
                    ErrorMessage.Text = ""
                End If

            End If
        Catch ex As Exception
            ErrorMessage.Text = ex.ToString()
        End Try
       
    End Sub

    Protected Sub CustCodeGetir(sender As Object, e As EventArgs) Handles Button10.Click
        i = 2
        KurumsalCustcodeSearch()
        MevcutTable2.Visible = True
        HidTable1.Visible = False
        KurumsalTable.Visible = True
    End Sub
    Private Sub KurumsalCustcodeSearch()
        Try
            LblError.Text = ""
            Dim custcode As String = TB_CustCode2.Text.Trim()

            Dim dt2 As DataTable = SMECustCodeSearch(custcode)


            If dt2.Rows.Count > 0 Then
                For Each dr2 As DataRow In dt2.Rows

                    MevcutAd.Text = dr2("ccfname").ToString() + "     " + dr2("cclname").ToString() + "," + dr2("CCCITY").ToString()
                    MevcutCustomer_id.Text = dr2("CUSTOMER_ID").ToString()
                    MevcutSicil.Text = dr2("CSCOMPTAXNO").ToString()
                    LblTcid.Text = dr2("CSTCIDNUMBER").ToString()
                    Button8.Enabled = True
                    ErrorMessage.Text = ""
                Next
                If LblTcid.Text = "" Then
                    Button8.Enabled = True
                Else
                    LblError.Text = TcControl(LblTcid.Text)
                    If LblError.Text <> "" Then
                        Button8.Enabled = False
                    Else
                        Button8.Enabled = True
                    End If


                End If



            Else
                Button8.Enabled = False
                ErrorMessage.Text = "Girmiş olduğunuz custcode için veri yoktur"

            End If
        Catch ex As Exception
            ErrorMessage.Text = ex.ToString()
        End Try
      



    End Sub

    Protected Sub BtnMevcutKurumsalCustomer(sender As Object, e As EventArgs) Handles Button8.Click
        Try
            Dim confirmValue As String = Request.Form("confirm_value")
            If confirmValue = "Yes" Then
                Session("Mevcut_Customer_id") = MevcutCustomer_id.Text
                Session("durum") = "MevcutSME" ' burada customer id nin SME'nin mevcut tablosundan geldiğini belirtilmistir
                Response.Redirect("HatAcilisiContractCreate.aspx")
            Else
                MevcutTable.Visible = True

            End If
        Catch ex As Exception
            ErrorMessage.Text = ex.ToString()
        End Try
       
    End Sub

    Protected Sub RadioButtonList3_SelectedIndexChanged(sender As Object, e As EventArgs) Handles RadioButtonList3.SelectedIndexChanged

        If RadioButtonList3.SelectedIndex = 0 Then
            Clear()
            MevcutTable2.Visible = True
            HidTable1.Visible = False
            KurumsalTable.Visible = True
            hidTable2.Visible = False
            i = 1
            'a = 1
            lblcode.Text = "mevcut"

        End If
        If RadioButtonList3.SelectedIndex = 1 Then
            Clear()
            hidTable2.Visible = True
            HidTable1.Visible = False
            KurumsalTable.Visible = True
            MevcutTable2.Visible = False
            i = 1
            MusteriGrubuSME()
            AktivasyonReasonSME()
            IlSecimSME()
            KimlikSecimSME()
            lblcode.Text = "kurumsalYeni"

            ' a = 2

        End If
    End Sub
    Public Shared Function NullControl(ByVal text As String) As String

        If text = "null" Then
            Return ""
        Else
            Return text
        End If



    End Function


    Protected Sub btnTCIDDogrulamaSME(sender As Object, e As EventArgs) Handles btnTCIDDogrulama0.Click
        hidTable2.Visible = True


        If SME_TB_CS_TC_ID.Text = "" Then

            Me.Page.RegisterStartupScript("javascript", "<script language=""javascript"">alert('TC No Alanı Boş Değer İçermez.');</script>")

        Else

            Try

                Dim d As Double = Double.Parse(SME_TB_CS_TC_ID.Text)

                If SME_TB_CS_TC_ID.Text.Length = 11 Then

                    Dim name, surname, gender, fatherName, birthDay, birthMonth, birthYear, cityName, countyName, anneKizlikSoyad, birthPlace As String

                    If (persistent.ChangeSIMpersistence.CheckMernisStatus2(SME_TB_CS_TC_ID.Text, name, surname, gender, fatherName, birthDay, birthMonth, birthYear, cityName, countyName, anneKizlikSoyad, birthPlace) = "0") Then



                        Label4.Text = "Geçerli TC No"
                        SME_TB_ADR_FNAME.Text = NullControl(name)
                        SME_TB_ADR_LNAME.Text = NullControl(surname)
                        SME_TB_CS_REMARK1.Text = NullControl(fatherName)
                        SME_TB_CS_REMARK2.Text = NullControl(anneKizlikSoyad)

                        SME_TB_CS_BIRTH_PROVINCE.Text = NullControl(birthPlace)
                        SME_TB_CS_REG_PROVINCE.Text = NullControl(cityName)
                        SME_TB_CS_REG_DISTRICT.Text = NullControl(countyName)
                        If birthDay.Length = 1 Then
                            birthDay = "0" + birthDay
                        End If
                        If birthMonth.Length = 1 Then
                            birthMonth = "0" + birthMonth
                        End If
                        SME_TDD_ADR_BIRTHDT.Text = birthDay + "." + birthMonth + "." + birthYear
                        If gender = "Erkek" Then
                            SME_DDL_ADR_SEX.SelectedIndex = 1
                        ElseIf gender = "Kadın" Then
                            SME_DDL_ADR_SEX.SelectedIndex = 2
                        Else
                            SME_DDL_ADR_SEX.SelectedIndex = 0
                        End If
                        lblMernisStatus.Text = 1

                        LblGLBLControl.Text = persistent.ChangeSIMpersistence.CheckSingleIwisResult(SME_TB_CS_TC_ID.Text)
                        If LblGLBLControl.Text = "OK" Then
                            Button2.Enabled = True
                        Else
                            Button2.Enabled = False
                        End If


                    Else

                        Label4.Text = "TC No geçerli değildir Lütfen tekrar deneyiniz"
                        lblMernisStatus.Text = 2

                        Me.Page.RegisterStartupScript("javascript", "<script language=""javascript"">alert('TC No geçerli değildir Lütfen tekrar deneyiniz');</script>")



                    End If

                Else

                    Label4.Text = "TC No Alanı 11 Karakter Olmalıdır."

                    Me.Page.RegisterStartupScript("javascript", "<script language=""javascript"">alert('TC No Alanı 11 Karakter Olmalıdır');</script>")



                End If

            Catch ex As Exception

                Me.Page.RegisterStartupScript("javascript", "<script language=""javascript"">alert('TC No Alanı Harf İçermez.');</script>")

            End Try



        End If


    End Sub

    Protected Sub SME_DDL_ADR_NATIONALITY_SelectedIndexChanged(sender As Object, e As EventArgs) Handles SME_DDL_ADR_NATIONALITY.SelectedIndexChanged
        If (SME_DDL_ADR_NATIONALITY.SelectedValue = 2) Then
            SME_TB_CS_TC_ID.Enabled = True
            btnTCIDDogrulama0.Visible = True
            btnTCIDDogrulama0.Enabled = True
            SME_TB_CS_TC_ID.Visible = True
            'RequiredFieldValidator1.ControlToValidate = "TB_CS_TC_ID"
            'HidTable1.Visible = True
            RequiredFieldValidator3.Enabled = True
        End If

        If (SME_DDL_ADR_NATIONALITY.SelectedValue <> 2) Then
            btnTCIDDogrulama0.Enabled = False
            btnTCIDDogrulama0.Visible = True
            SME_TB_CS_TC_ID.Enabled = False
            SME_TB_CS_TC_ID.Visible = True
            SME_TB_CS_TC_ID.Text = ""
            RequiredFieldValidator3.Enabled = False
            Button2.Enabled = True
            LblGLBLControl.Text = ""
            Label4.Text = ""

        End If

    End Sub

    Protected Sub DDL1_ADR_NOTE1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DDL1_ADR_NOTE1.SelectedIndexChanged
        Try
            DDL1_ADR_SEMT.Items.Clear()
            TB1_ADR_ZIP.Text = ""
            DDL1_ADR_SEMT.Items.Add(New ListItem("--Seçiniz--", ""))
            Dim dt As DataTable = New DataTable()
            dt = ccapps.persistent.YenidenAktivasyon.Autostreet(Convert.ToInt32(DDL1_ADR_NOTE1.SelectedItem.Value), Convert.ToInt32(lblcitycode.Text))

            For Each dr2 As DataRow In dt.Rows
                DDL1_ADR_SEMT.Items.Add(New ListItem(dr2("street_des").ToString(), dr2("ST_STREET_COD").ToString()))
            Next
            DDL1_ADR_SEMT.Items.Add(New ListItem("Tanımsız", "."))
        Catch ex As Exception

        End Try
        
    End Sub

    Protected Sub DDL1_ADR_SEMT_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DDL1_ADR_SEMT.SelectedIndexChanged
     
        TB1_ADR_ZIP.Text = ""
        Try
            Dim dt As DataTable = ccapps.persistent.YenidenAktivasyon.AutoZIPCOD(Convert.ToInt32(DDL1_ADR_SEMT.SelectedItem.Value))
            If dt.Rows.Count > 0 Then
                TB1_ADR_ZIP.Text = dt.Rows(0)(0).ToString().Trim()
            End If
        Catch ex As Exception

        End Try


    End Sub

    Protected Sub SME_DDL1_ADR_NOTE1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles SME_DDL1_ADR_NOTE1.SelectedIndexChanged
        Try
            SME_DDL1_ADR_SEMT.Items.Clear()
            SME_TB1_ADR_ZIP.Text = ""
            SME_DDL1_ADR_SEMT.Items.Add(New ListItem("--Seçiniz--", ""))
            Dim dt As DataTable = New DataTable()
            dt = ccapps.persistent.YenidenAktivasyon.Autostreet(Convert.ToInt32(SME_DDL1_ADR_NOTE1.SelectedItem.Value), Convert.ToInt32(lblcitycode.Text))
            For Each dr2 As DataRow In dt.Rows
                SME_DDL1_ADR_SEMT.Items.Add(New ListItem(dr2("street_des").ToString(), dr2("ST_STREET_COD").ToString()))
            Next
            SME_DDL1_ADR_SEMT.Items.Add(New ListItem("Tanımsız", "."))

        Catch ex As Exception

        End Try
       
    End Sub

    Protected Sub SME_DDL1_ADR_SEMT_SelectedIndexChanged(sender As Object, e As EventArgs) Handles SME_DDL1_ADR_SEMT.SelectedIndexChanged


        SME_TB1_ADR_ZIP.Text = ""
        Try
            Dim dt As DataTable = ccapps.persistent.YenidenAktivasyon.AutoZIPCOD(Convert.ToInt32(SME_DDL1_ADR_SEMT.SelectedItem.Value))
            If dt.Rows.Count > 0 Then
                SME_TB1_ADR_ZIP.Text = dt.Rows(0)(0).ToString().Trim()
            End If
        Catch ex As Exception

        End Try

    End Sub

    Protected Sub TOP_DDL1_ADR_NOTE1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles TOP_DDL1_ADR_NOTE1.SelectedIndexChanged
        Try
            TOP_DDL1_ADR_SEMT.Items.Clear()
            TOP_TB1_ADR_ZIP.Text = ""
            TOP_DDL1_ADR_SEMT.Items.Add(New ListItem("--Seçiniz--", ""))
            Dim dt As DataTable = New DataTable()
            dt = ccapps.persistent.YenidenAktivasyon.Autostreet(Convert.ToInt32(TOP_DDL1_ADR_NOTE1.SelectedItem.Value), Convert.ToInt32(lblcitycode.Text))

            For Each dr2 As DataRow In dt.Rows
                TOP_DDL1_ADR_SEMT.Items.Add(New ListItem(dr2("street_des").ToString(), dr2("ST_STREET_COD").ToString()))
            Next
            TOP_DDL1_ADR_SEMT.Items.Add(New ListItem("Tanımsız", "."))
        Catch ex As Exception

        End Try
      
    End Sub

    Protected Sub TOP_DDL1_ADR_SEMT_SelectedIndexChanged(sender As Object, e As EventArgs) Handles TOP_DDL1_ADR_SEMT.SelectedIndexChanged


        TOP_TB1_ADR_ZIP.Text = ""
        Try
            Dim dt As DataTable = ccapps.persistent.YenidenAktivasyon.AutoZIPCOD(Convert.ToInt32(TOP_DDL1_ADR_SEMT.SelectedItem.Value))
            If dt.Rows.Count > 0 Then
                TOP_TB1_ADR_ZIP.Text = dt.Rows(0)(0).ToString().Trim()
            End If
        Catch ex As Exception

        End Try

    End Sub

    Protected Sub SUB_DDL1_ADR_NOTE1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles SUB_DDL1_ADR_NOTE1.SelectedIndexChanged
        Try
            SUB_DDL1_ADR_SEMT.Items.Clear()
            SUB_TB1_ADR_ZIP.Text = ""
            SUB_DDL1_ADR_SEMT.Items.Add(New ListItem("--Seçiniz--", ""))
            Dim dt As DataTable = New DataTable()
            dt = ccapps.persistent.YenidenAktivasyon.Autostreet(Convert.ToInt32(SUB_DDL1_ADR_NOTE1.SelectedItem.Value), Convert.ToInt32(lblcitycode.Text))
            For Each dr2 As DataRow In dt.Rows
                SUB_DDL1_ADR_SEMT.Items.Add(New ListItem(dr2("street_des").ToString(), dr2("ST_STREET_COD").ToString()))
            Next
            SUB_DDL1_ADR_SEMT.Items.Add(New ListItem("Tanımsız", "."))

        Catch ex As Exception

        End Try
       
    End Sub

    Protected Sub SUB_DDL1_ADR_SEMT_SelectedIndexChanged(sender As Object, e As EventArgs) Handles SUB_DDL1_ADR_SEMT.SelectedIndexChanged
    

        SUB_TB1_ADR_ZIP.Text = ""
        Try
            Dim dt As DataTable = ccapps.persistent.YenidenAktivasyon.AutoZIPCOD(Convert.ToInt32(SUB_DDL1_ADR_SEMT.SelectedItem.Value))
            If dt.Rows.Count > 0 Then
                SUB_TB1_ADR_ZIP.Text = dt.Rows(0)(0).ToString().Trim()
            End If
        Catch ex As Exception

        End Try
    End Sub
End Class